import React from 'react'
import { withRouter, NavLink } from 'react-router-dom'
import { observer, inject } from 'mobx-react'
import Header from './header'
import Main from './main'
@withRouter //更新数据
@inject('five') //获取数据
@observer //让页面变成响应式
class Top extends React.Component {
    constructor(props) {
        super(props)
        this.state = {
            ajaxCfg: {
                url: '/home/mediareports',
                cfg: {
                    page_number: '1',
                    page_size: '10'
                },
                headers: {}
            }
        }
    }
    //拼多多调用
    getList(ajaxCfg) {
        const { getPdd } = this.props.five;
        getPdd(ajaxCfg)
    }
    componentDidMount() {
        // this.init()
        this.getList(this.state.ajaxCfg)
    }
    //全新的页面内容添加思路
    lists() {
        const { paddlist } = this.props.five
        const lists = paddlist.map((val, index) => {
            return (
                <li key={val.id}>
                    {val.id}内容
                </li>
            )
        })
        return lists
    }
    render() {
        // console.log(this.props.five.paddlist.length)
        const { paddlist } = this.props.five
        return (
            <React.Fragment>
                
                {/* {this.lists()}
                {
                    paddlist.length === 0 ? '' : paddlist.length
                } */}
                {this.props.five.data}
                <Header/>
                <Main/>
            </React.Fragment>
        )
    }
}
export default Top

